import {request} from "@utils/http";
import {addArticleValid, getListValid, updateListValid} from "@api/Article/index.valid";

/**
 * @description 发布文章
 *
 */

export const publishArticleAPI = (data: addArticleValid) => {
    return request({
        url: '/article/createArticle',
        method: 'post',
        data
    })
}

/**
 * @description 更新文章
 *
 */
export const updateArticleAPI = (data: updateListValid) => {
    return request({
        url: `/article/updateArticle`,
        method: 'post',
        data
    })
}
/**
 * @description 获取文章列表
 *
 */
export const getArticleListAPI = (data: getListValid) => {
    return request({
        url: '/article/getArticleList',
        method: 'post',
        data: {
            page: data.page,
            pageSize: data.pageSize,
            sort: data.sort,
            filter: data.filter
        }
    })
}

/**
 * @description 获取文章详情
 */
export const getArticleDetailAPI = (id: string) => {
    return request({
        url: `/article/getArticleDetail/${id}`,
        method: 'get'
    })
}

/**
 * @description 删除文章
 */

export const deleteArticleAPI = (id: string | any) => {
    return request({
        url: `/article/deleteArticle`,
        method: 'post',
        data: {
            id: id
        }
    })
}
